﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using taxi_sovereign.view;
using taxi_sovereign.interfaces;
using taxi_sovereign.model;
using taxi_sovereign.controls;
using taxi_sovereign.analyze;

namespace taxi_sovereign
{
    static class Program
    {
       
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            TEST();
            Form1 mainform = new Form1();
            Application.Run(mainform);
            
           
           
        }
        
        static void TEST()
        {
            Model testmodel = new Model();
            ModelSettings testsettings = new ModelSettings();
           
             List<IVehicle> testvehicles = new List<IVehicle>();
             Cross cross1 = new Cross(30, 20);
             Cross cross2 = new Cross(90, 160);
             Cross cross3 = new Cross(170, 40);
             Cross cross4 = new Cross(230, 200);
             Cross cross5 = new Cross(160, 300);
             Cross cross6 = new Cross(360, 300);
             Cross cross7 = new Cross(300, 200);
             Road road24 = new Road(cross2, cross4, "улица 2-4");
             Road road13 = new Road(cross1, cross3, "улица 1-3");
             Road road45 = new Road(cross4, cross5, "скоростная трасса");
             Road road12 = new Road(cross1, cross2, "улица 1-2");
             Road road23 = new Road(cross2, cross3, "улица 2-3");
             Road road56 = new Road(cross5, cross6, "Горная тропа ");
             Road road67 = new Road(cross6, cross7, "улица 6-7");
             IStop stop231 = (IStop)new Stop(road23.GetLength()/2);
             IStop stop232 = (IStop)new Stop(road23.GetLength()/4);
             IStop stop12 = (IStop)new Stop(road12.GetLength()/2);
             IStop stop42 = new Stop(road24.GetLength() / 2);
             IStop stop67 = (IStop)new Stop(road67.GetLength() / 2);
             road45.SPEEDModifier = 3;
             road56.SPEEDModifier = 0.6F;
             stop12.AddPass(new Passenger((IStop)stop12, (IStop)stop232, 10000));
             stop12.AddPass(new Passenger((IStop)stop12, (IStop)stop232, 10000));
             stop12.AddPass(new Passenger((IStop)stop12, (IStop)stop231, 10000));
             stop12.AddPass(new Passenger((IStop)stop12, (IStop)stop231, 10000));
             stop12.AddPass(new Passenger((IStop)stop12, (IStop)stop231, 10000));
             stop42.AddPass(new Passenger((IStop)stop42, (IStop)stop231, 10000));
             stop232.AddPass(new Passenger((IStop)stop232, (IStop)stop231, 10000));
             stop67.AddPass(new Passenger((IStop)stop67, (IStop)stop231, 10000));
            

             IStop[] stops1 = new IStop[] { (IStop)stop12 };
             road12.SetStops(stops1);
             IStop[] stops2 = new IStop[] { (IStop)stop231, (IStop)stop232 };
             road23.SetStops(stops2);
             road24.SetStops(new IStop[] { stop42 });
             road67.SetStops(new IStop[] { stop67 });



             Route testroute = new Route(new IRoad[] { road12, road23 }, new IStop[] {stop12, stop232, stop231 });
             testvehicles.Add(new Vehicle("testbus", testroute, road12, cross1));
             Route testroute2 = new Route(new IRoad[] { road67,road56,road45, road24, road23 }, new IStop[] {stop67, stop42, stop232, stop231 });
             testvehicles.Add(new Vehicle("testbus2", testroute2, road45, cross5));
             testvehicles.Add(new Vehicle("testbus32", testroute2, road67, cross7));
             testsettings.SetVehicles(testvehicles);
             List<IRoad> testroadslist = new List<IRoad>();
             testroadslist.Add(road12);
             testroadslist.Add(road23);
             testroadslist.Add(road24);
             testroadslist.Add(road13);
             testroadslist.Add(road45);
             testroadslist.Add(road56);
             testroadslist.Add(road67);
             List<ICross> testcrosseslist = new List<ICross>();
             testcrosseslist.Add(cross1);
             testcrosseslist.Add(cross2);
             testcrosseslist.Add(cross3);
             testcrosseslist.Add(cross4);
             testcrosseslist.Add(cross5);
             testcrosseslist.Add(cross6);
             testcrosseslist.Add(cross7);

             testsettings.SetRoads(testroadslist);
             testsettings.SetCrosses(testcrosseslist);

             testsettings.SaveModelSettingsToFile("settngs.tss");
             testsettings.LoadModelSettingsFromFile("settngs.tss");
            testmodel.SetModelSettings(testsettings);
            //testmodel.Start();
            Logger.AddToLog("tstmodelstarted");
            Logger.AddToLog("LoggerTest");
            Painter.SetModel(testmodel);
            Editor.SetModel(testmodel);
            MouseCtrl.SetModel(testmodel);
            ModelCtrl.SetModel(testmodel);
            ModelCtrl.LoadGeneralPropsFromFile("General.tsg");
            Analyzer.SetModel(testmodel);

            //Logger.SaveLog("log.txt");
        }
    }
}